<template>
    <div>
        <div class="searchPage" ref="searchPage">
            <div>
                <div class="titlepage">
                    <div v-for="(item, index) in searchPage.sortTitle" :class="searchPage.sort==item.sortKey?'active':''" :key="'sortTitle'+index" @click="switchTitle(item.sortKey)">{{item.title}}</div>
                </div>
                <guessLike :guessLike="searchPage.guessLike" :lable="true"></guessLike>
            </div>
        </div>
        <shoppingFloat></shoppingFloat>
    </div>
</template>

<script>
import BScroll from 'better-scroll';
import guessLike from '../components/GuessLike';
import shoppingFloat from '../components/ShoppingFloat';

import {mapState,mapMutations,mapActions} from 'vuex';

export default {
    components:{
        guessLike,
        shoppingFloat,
    },
    computed:{
        ...mapState(["searchPage"]),
    },
    data(){
        return {
           
        }
    },
    methods:{
        initScroll(){
            setTimeout(()=>{
                new BScroll(this.$refs.searchPage,{click:true});
            },100)
        },
        switchTitle(e){
            this.$store.commit("setSearchSort",e);
            this.searchLoad();
        },
        ...mapActions(["searchLoad"]),
    },
    mounted(){
        this.initScroll();
        this.searchLoad();
    }
}
</script>

<style lang="less" scoped>
.searchPage{
    position: absolute;
    top: @h;
    bottom: 0;
    width: 100%;
    .titlepage{
        display: flex;
        padding:23px 0px;
        border-top: 1px solid @cc;
        border-bottom: 1px solid @cc;
        margin:15px 0px;
        div{
            flex-grow:1;
            text-align: center;
            border-right: 1PX solid @cc;
            box-sizing: border-box;
            font-size: 30px;
        }
        .active{
            color: @light-pink;
        }
        div:last-child{
            border-right: 0px;

        }
    }
}
</style>
